home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 84 / applic / echo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-12-19  |  2.8 KB  |  101 lines

  1. /*******************************************************************/
  2. /*                                     */
  3. /*        echo.c     -    program to convert fonts         */
  4. /*                        from ***.FED to ***.FNT  */
  5. /*                        format for use with GDOS */
  6. /*                                     */
  7. /*                        compiles as "echo.ttp"   */
  8. /*                        argument 1 - name.FED    */
  9. /*                        argument 2 - name.FNT    */
  10. /*                                     */
  11. /*        This program converts .FED files, which                  */
  12. /*        are in standard data format (high byte           */
  13. /*        first) to .FNT files in INTEL format (low                */
  14. /*        byte first) - also resets the offset table               */
  15. /*        and data pointers to point to the data           */
  16. /*        postion in the file, as GDOS expects.            */
  17. /*        More info in the GEM/atari.st topic.             */
  18. /*                                     */
  19. /*        written in Megamax C for the Atari ST            */
  20. /*                                     */
  21. /*        John D. Ruley      -       August 1985           */
  22. /*                                     */
  23. /*******************************************************************/
  24.  
  25. #include <stdio.h>
  26. #include <osbind.h>
  27.  
  28. main(argc,argv)
  29. int argc;
  30. char *argv[];
  31. {
  32. int i,j;
  33. char in_name[30],out_name[30],in_buf[4],out_buf[4];
  34. int in_chan,out_chan;
  35.  
  36. if(argc < 2){
  37.     printf("bad arguments\n");
  38.     i = Cconin();
  39.     }
  40.  
  41. strcpy(in_name,argv[1]);           /* file for input "xxx.FED" */
  42. strcpy(out_name,argv[2]);          /* file for output "xx.FNT" */
  43.  
  44. in_chan = Fopen(in_name,0);
  45. out_chan = Fcreate(out_name,0);
  46.  
  47. printf("converting %s to GDOS .FNT format as %s\n",in_name,out_name);
  48.  
  49.     j = Fread(in_chan,2L,in_buf);   /* font I.D. */
  50.     out_buf[1] = in_buf[0];
  51.     out_buf[0] = in_buf[1];
  52.     Fwrite(out_chan,2L,out_buf);
  53.  
  54.     j = Fread(in_chan,2L,in_buf);   /* font size */
  55.     out_buf[1] = in_buf[0];
  56.     out_buf[0] = in_buf[1];
  57.     Fwrite(out_chan,2L,out_buf);
  58.  
  59. for(i = 0;i<16;i++){                /* face name */
  60.     j = Fread(in_chan,2L,in_buf);
  61.     Fwrite(out_chan,2L,in_buf);
  62.     }
  63.  
  64. for(i = 0;i<16;i++){                /* assorted stuff */
  65.     j = Fread(in_chan,2L,in_buf);
  66.     out_buf[1] = in_buf[0];
  67.     out_buf[0] = in_buf[1];
  68.     Fwrite(out_chan,2L,out_buf);
  69.     }
  70.  
  71. for(i=0;i<2;i++){                   /* offset pointers */
  72.     j = Fread(in_chan,4L,in_buf);
  73.     out_buf[0] = 88;                /* 058 Hex - start of data */
  74.     out_buf[1] = 0;
  75.     out_buf[2] = 0;
  76.     out_buf[3] = 0;
  77.     Fwrite(out_chan,4L,out_buf);
  78.     }
  79.  
  80.     j = Fread(in_chan,4L,in_buf);   /* pointer to font data */
  81.     out_buf[0] = 90;                /* 025A Hex -  */
  82.     out_buf[1] = 2;
  83.     out_buf[2] = 0;
  84.     out_buf[3] = 0;
  85.     Fwrite(out_chan,4L,out_buf);
  86.                                     /* whatever's left... */
  87.  
  88. while((i = Fread(in_chan,2L,in_buf)) != 0){
  89.     out_buf[1] = in_buf[0];
  90.     out_buf[0] = in_buf[1];
  91.     Fwrite(out_chan,2L,out_buf);
  92.     }
  93.  
  94. Fclose(in_chan);                    /* close the files */
  95. Fclose(out_chan);
  96.  
  97. printf("inversion is complete\n");  /* and quit !      */
  98. Cconin();                           /* after any char  */
  99. exit();
  100. }
  101.